const moment = require('moment');
const momentRange = require('moment-range');
// 将 moment-range 扩展到 moment 对象
const momentWithRange = momentRange.extendMoment(moment);
const today = moment();

// 创建一个从 2025 年 1 月 1 日到今天的日期范围
const staTime = momentWithRange('2025-01-01');
// const endTime = momentWithRange('2035-12-31');
// 获取今天的时间
const endTime = today.format('YYYY-MM-DD');
const range = momentWithRange.range(staTime, endTime);

let dates = {
	years:[],
	months:[],
	days:[]
};
for (let date of range.by('day')) {
	let year = date.format('YYYY');
	let month = date.format('MM');
	let day = date.format('DD');
	
	// 查找年份索引，如果不存在则添加
	let yearIndex = dates.years.indexOf(year);
	if (yearIndex === -1) {
		yearIndex = dates.years.length;
		dates.years.push(year);
		dates.months.push([]);
		dates.days.push([]);
	}
	
	// 查找月份索引，如果不存在则添加
	let monthIndex = dates.months[yearIndex].indexOf(month);
	if (monthIndex === -1) {
		monthIndex = dates.months[yearIndex].length;
		dates.months[yearIndex].push(month);
		dates.days[yearIndex].push([]);
	}
	
	// 添加日期
	dates.days[yearIndex][monthIndex].push(day);
}

export default dates;